package vo

type SwDeviceStatus int

const (
	SwDeviceStatusNone SwDeviceStatus = iota
	SwDeviceStatusRunning
	SwDeviceStatusStopped
)

type SwDeviceInfo struct {
	Sid      int32
	Status   SwDeviceStatus
	StopChan chan struct{}
}

func (info *SwDeviceInfo) GetStatus() SwDeviceStatus {
	if info == nil {
		return SwDeviceStatusNone
	}
	return info.Status
}

func (info *SwDeviceInfo) SetStatus(deviceStatus SwDeviceStatus) {
	if info == nil {
		return
	}
	info.Status = deviceStatus
}

func (info *SwDeviceInfo) SetSid(sid int32) {
	if info == nil {
		return
	}
	info.Sid = sid
}

func (info *SwDeviceInfo) CloseStopChan() {
	select {
	case info.StopChan <- struct{}{}:
	default:
	}
}

func NewSwDeviceInfo() *SwDeviceInfo {
	return &SwDeviceInfo{
		Status:   SwDeviceStatusNone,
		StopChan: make(chan struct{}, 1),
	}
}
